package com.wlyuan.open.domain;

import com.wlyuan.core.marker.NamedValue;
import com.wlyuan.core.marker.NamedValues;
import lombok.RequiredArgsConstructor;
import lombok.ToString;

import java.util.Map;

@RequiredArgsConstructor
@ToString
public class PushTaskStatus implements NamedValue<Integer> {
    private final Integer value;
    private final String name;

    public static PushTaskStatus CREATED = new PushTaskStatus(1,"待推送");
    public static PushTaskStatus SUCCEED = new PushTaskStatus(2,"推送成功");
    public static PushTaskStatus FAILED = new PushTaskStatus(3,"推送失败");

    private final static Map<Integer,PushTaskStatus> MAP = new NamedValues<Integer, PushTaskStatus>(PushTaskStatus.class);

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    public static PushTaskStatus fromValue(Integer value){
        if(value == null){
            return null;
        }
        return MAP.get(value);
    }
}
